<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<title>鲁班 - 菜单编辑器</title>
		<!--[if lt IE 9]>
	    	<meta http-equiv="refresh" content="/ie" />
	    <![endif]-->
		<link rel="shortcut icon" href="favicon.ico">
	    <link th:href="@{/components/bootstrap/3.3.7/css/bootstrap.min.css}" rel="stylesheet">
		<link th:href="@{/components/font-awesome/4.6.3/css/font-awesome.min.css}" rel="stylesheet">
	    <link th:href="@{/css/animate.min.css}" rel="stylesheet">
	    <link th:href="@{/css/style.css}" rel="stylesheet">
	    <style>
			.edit-menus span {
				color: #fff;
				padding: 5px 8px;
				border-radius: 4px;
				font-weight: normal;
				top: 0;
			}
			
			.edit-menus span.glyphicon-search {
				background: #12D6B2;
			}
			
			.edit-menus span.glyphicon-edit {
				background: #0F8FDA;
			}
			
			.edit-menus span.glyphicon-trash {
				background: #F30446;
			}
			
			.edit-menus span.glyphicon-plus {
				background: #12D6B2;
			}
			
			.dd-nodrag.end {
				padding: 10px;
				display: block;
				margin: 5px 0;
				color: #333;
				text-decoration: none;
				border: 1px solid #e7eaec;
				background: #D2D2D2;
				border-radius: 3px;
				box-sizing: border-box;
				-moz-box-sizing: border-box;
				cursor: pointer;
				-webkit-user-select: none;
				-moz-user-select: none;
				user-select: none;
			}
		</style>
	</head>
	<body class="gray-bg">
		<div class="wrapper wrapper-content  animated fadeInRight">
			<div class="row">
				<div class="col-sm-4">
					<div id="nestable-menu">
						<button type="button" data-action="expand-all" class="btn btn-white btn-sm">展开所有</button>
						<button type="button" data-action="collapse-all" class="btn btn-white btn-sm">收起所有</button>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="ibox ">
						<div class="ibox-title">
							<h5>菜单设计器</h5>
						</div>
						<div class="ibox-content">
							<p class="m-b-lg">
								菜单设计器将根据用户设计来展示后台菜单展示情况
								删除的时候请小心，他可能会让你的菜单不可用
								删除时如有子菜单，将会一并删除
								排序性能较低，请谨慎操作
								请根据实际需求来调整菜单
							</p>
							<div class="dd" id="nestable">
								<ol th:if="${resList ne null}" class="dd-list">
									<div th:replace="this::res(${resList}, 0, 0)"></div>
								</ol>
								<!-- 第一次添加初始化 -->
								<ol th:unless="${resList ne null}" class="dd-list">
									<li class="dd-item add" data-id="0" th:data-sort="0" th:data-parent-id="0">
										<div class="dd-nodrag end">
											<span class="glyphicon glyphicon-plus" th:text="添加菜单"></span> 
										</div>
									</li>
								</ol>
							</div>
							<div class="m-t-md">
								<h5>数据：</h5>
							</div>
							<textarea id="nestable-output" class="form-control"></textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" th:src="@{/js/common/require.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/common/config.js}"></script>
		<script type="text/javascript" th:src="@{/js/module/sys/resource/sys_resource_list.js}"></script>
		<!--局部模板-->
		<th:block th:fragment="res(rList, pid, sortNo)">
			<th:block th:each="r : ${rList}">
				<li th:class="${pid eq 0} ? 'dd-item parents':'dd-item'" th:data-id="${r.id}" th:data-sort-no="${r.sortNo}" th:data-pid="${r.pid}" th:with="sortNo=${r.sortNo}">
					<div class="dd-handle">
						<span class="label label-info"><i th:class="${r.icon}"></i></span> <span th:text="${r.name}"></span>
						<div class="dd-nodrag pull-right edit-menus">
							<span class="glyphicon glyphicon-search">查看</span>
							<span class="glyphicon glyphicon-edit">编辑</span>
							<span class="glyphicon glyphicon-trash">删除</span>
						</div>
					</div>
					<ol class="dd-list">
						<th:block th:unless="${#lists.isEmpty(r.children)}" th:include="this::res(${r.children}, ${r.id}, ${r.sortNo})"/>
						<li th:if="${#lists.isEmpty(r.children)}" class="dd-item add" data-id="0" th:data-sort-no="0" th:data-pid="${r.id}">
							<div class="dd-nodrag end">
								<span class="glyphicon glyphicon-plus" th:text="添加子菜单"></span> 
							</div>
						</li>
					</ol>
				</li>
			</th:block>
			<li class="dd-item add" data-id="0" th:data-sort-no="${sortNo} + 1" th:data-pid="${pid}">
				<div class="dd-nodrag end">
					<span class="glyphicon glyphicon-plus" th:text="${pid eq 0} ? '添加菜单' : '添加子菜单'"></span> 
				</div>
			</li>
		</th:block>
	</body>
</html>